package com.itheima.泛型.sort;

import java.util.TreeSet;

/**
 * @Author 王加鑫
 * @Date 2021/5/14 15:45
 * @Version 1.0
 */
public class SortTest {
    public static void main(String[] args) {
        TreeSet<String> set = new TreeSet<>(
                ((o1, o2) -> {
                    int res = o1.length() - o2.length();
                    res = res == 0 ? o1.compareTo(o2) : res;
                    return res;

                })
        );
        set.add("c");
        set.add("ab");
        set.add("df");
        set.add("qwer");
        set.add("qwer");
        System.out.println(set);

    }
}
